package design.principle;

import java.util.ArrayList;
import java.util.List;

/**
 * @program JavaBase
 * @description: 迪米特法则
 * @author: zhanglu
 * @create: 2020-03-26 17:26:00
 */
public class LawOfDemeter {

    public static void main(String[] args) {
//        Teacher teacher = new Teacher();
//        teacher.commond(new GroupLeader());

        Teacher2 teacher2 = new Teacher2();

        List<Girl> girlList = new ArrayList<>();
        for (int i = 0; i < 15; i++) {
            girlList.add(new Girl());
        }

        teacher2.commond(new GroupLeader2(girlList));

    }

}

class Teacher{

    void commond(GroupLeader groupLeader){

        List<Girl> girlList = new ArrayList<>();
        for (int i = 0; i < 18; i++) {
            girlList.add(new Girl());
        }

        groupLeader.countGirls(girlList);

    }

}

class GroupLeader{

    void countGirls(List<Girl> girlList){
        System.out.println("总计：" + girlList.size());
    }

}

class Girl{

}

class Teacher2{

    void commond(GroupLeader2 groupLeader2){
        groupLeader2.countGirls();
    }

}

class GroupLeader2{

    private List<Girl> girlList;

    public GroupLeader2(List<Girl> girlList) {
        this.girlList = girlList;
    }

    void countGirls(){
        System.out.println("总计：" + girlList.size());
    }

}


